package com.wds.controller;

import com.wds.domain.JsonResult;
import com.wds.domain.dto.ArticleAddDto;
import com.wds.domain.dto.ArticleUpdateDto;
import com.wds.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author WDs , wds8.24@outlook.com
 * @version 1.0
 * @since 2022-12-31 9:47
 */
@RestController
@RequestMapping("/content/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @PostMapping()
    public JsonResult<Object> addNewArticle(@RequestBody ArticleAddDto dto){
        return articleService.addNewArticle(dto);
    }
    @GetMapping("/list")
    public JsonResult<Object> listAllArticle(Integer pageNum, Integer pageSize,String title,String summary){
        return articleService.listAllArticle(pageNum, pageSize, title, summary);
    }
    @GetMapping("/{id}")
    public JsonResult<Object> queryOne(@PathVariable Long id){
        return articleService.queryOne(id);
    }
    @PutMapping()
    public JsonResult<Object> updateArticle(@RequestBody ArticleUpdateDto articleDto){
        return articleService.updateArticle(articleDto);
    }
    @DeleteMapping("{ids}")
    public JsonResult<Object> deleteArticle(@PathVariable List<Long> ids){
        return articleService.deleteArticle(ids);
    }
}
